
#ifndef __ACQUIRE_API_CLIENT_H
#define __ACQUIRE_API_CLIENT_H

#include <stdint.h>

#ifndef __WIN32__
#define EXPORTED
#define EXPORTABI
#else
#ifdef _WINDLL
#define EXPORTED __declspec(dllexport)
#else
#define EXPORTED __declspec(dllimport)
#endif
#define EXPORTABI __cdecl
#endif

EXPORTED int EXPORTABI AcquireClientStateIsIncomplete();

EXPORTED const char * EXPORTABI AcquireClientGetUsername();

EXPORTED int EXPORTABI AcquireClientInit(const char *hostname, int portno, const char *username, const char *password, const char *brokername);
EXPORTED void EXPORTABI AcquireClientInitLibraries();
EXPORTED int EXPORTABI AcquireClientInitState(const char *hostname, int portno, const char *username, const char *password, const char *brokername);

EXPORTED void EXPORTABI AcquireClientDestroyState();

EXPORTED void EXPORTABI AcquireClientDestroy();

EXPORTED void EXPORTABI AcquireClientClearResults();

EXPORTED int EXPORTABI AcquireUpdateKeys();

#define ACQUIRE_USER_REGISTER__USER_IS_AUTHORISED      1
#define ACQUIRE_USER_REGISTER__IS_ACCEPTED_FOR_REVIEW  2
#define ACQUIRE_USER_REGISTER__NAME_IS_INVALID         3
#define ACQUIRE_USER_REGISTER__USER_PENDING_REVIEW     4

#define ACQUIRE_USER_REGISTRATION_STATE__INVALID       1
#define ACQUIRE_USER_REGISTRATION_STATE__INCOMPLETE    2
#define ACQUIRE_USER_REGISTRATION_STATE__FINAL         3

EXPORTED int EXPORTABI AcquireRegisterUserWithBroker();

EXPORTED int EXPORTABI AcquireGenerateInitialXMLWorkDescriptor(const char *descrfilename, const char *workname, const char *examplechain, const char *capabilities, int64_t maxtimesecs);

EXPORTED const char * EXPORTABI AcquireReserveWorkStore(const char *descrfilename, const char *inputdirectory, int64_t *remotespace, int *blocks, int *cancel);

#define ACQUIRE_DELETE_WORK_STORE__UNKNOWN_ERROR      -1
#define ACQUIRE_DELETE_WORK_STORE__ACCESS_DENIED       0
#define ACQUIRE_DELETE_WORK_STORE__SUCCESS             1

EXPORTED int EXPORTABI AcquireDeleteWorkStore(const char *store_id);

EXPORTED int EXPORTABI AcquireUploadToWorkStore(const char *store_id, const char *inputdirectory, const char *clusterid, const char *password, int instances, int maxtimesecs, int *blocksdone, int *cancelflag);

EXPORTED int EXPORTABI AcquireDownloadFromWorkStore(const char *store_id, const char *results_id, const char *outputdirectory, int *blocksdone, int *expected, int *cancelflag);

EXPORTED int EXPORTABI AcquireAreResultsFromWorkStoreReady(const int nresultsarray, int *resultsarray, const char *store_id);

EXPORTED const char * EXPORTABI AcquireGetResultIDFromNumberWhenReady(const int resultno, const char *store_id);

EXPORTED int EXPORTABI AcquireQueryAllWorkDataStatus(const char *store_id, char ***data_ids, char **stage_at, float **pct_complete, int *noofwds);

EXPORTED int EXPORTABI AcquireQueryWorkStatus(const char *store_id, float *pct_broker2compute, float *pct_complete, float *pct_compute2broker);

#define ACQUIRE_QUERY_ALL_WORK__PARSE_ERROR         -2
#define ACQUIRE_QUERY_ALL_WORK__UNKNOWN_ERROR       -1
#define ACQUIRE_QUERY_ALL_WORK__ACCESS_DENIED        0
#define ACQUIRE_QUERY_ALL_WORK__SUCCESS              1
#define ACQUIRE_QUERY_ALL_WORK__SUCCESS_NO_WORK      2

EXPORTED int EXPORTABI AcquireQueryAllWorkStatus(char ***store_ids, float **pct_broker2compute, float **pct_complete, float **pct_compute2broker, int *noofstores, int64_t *quota);

#define ACQUIRE_USER_ADD_SSH__SSH_SUCCESS            1
#define ACQUIRE_USER_ADD_SSH__FINGERPRINT_UNTRUSTED  2
#define ACQUIRE_USER_ADD_SSH__SSH_ROUTING_FAILED     3

EXPORTED int EXPORTABI AcquireAddSSHHostToPool(const char *username_at_remotemachine, const char *password, char **list_of_failed_hosts, char *deus_ex_filename);

EXPORTED const char * EXPORTABI AcquireListOfAccessibleClusters();

EXPORTED int EXPORTABI AcquireClientIsInitialised();

// Hack to expose host and port defaults without redefinition

#include "default_hosts.h"

#endif
